-module(db).
-export([init/0]).
-include("records.hrl").

init() ->
	mnesia:create_schema([jordi@stockholm]),
	mnesia:start(),
	mnesia:create_table(user, [
			{disc_copies, [jordi@stockholm]},
			{type, ordered_set},
			{index, [name]},
			{attributes, record_info(fields, user)}]),
	mnesia:create_table(homework, [
			{disc_copies, [jordi@stockholm]},
			{type, ordered_set},
			{attributes, record_info(fields, homework)}]),
	mnesia:create_table(homework_to_do, [
			{disc_copies, [jordi@stockholm]},
			{type, bag},
			{attributes, record_info(fields, homework_to_do)}]),
	mnesia:create_table(homework_to_correct, [
			{disc_copies, [jordi@stockholm]},
			{type, bag},
			{attributes, record_info(fields, homework_to_correct)}]),
	mnesia:create_table(homework_to_rate, [
			{disc_copies, [jordi@stockholm]},
			{type, bag},
			{attributes, record_info(fields, homework_to_rate)}]),
	mnesia:create_table(homework_finished, [
			{disc_copies, [jordi@stockholm]},
			{type, bag},
			{attributes, record_info(fields, homework_finished)}]),
	mnesia:create_table(audio, [
			{disc_copies, [jordi@stockholm]},
			{type, ordered_set},
			{index, [language]},
			{attributes, record_info(fields, audio)}]).
